package com.company.笔试.数组中出现次数超过一半的数组;

public class Solution {
    public int MoreThanHalfNum_Solution(int [] array) {
        int count = 0 ;//票数
        int res = 0 ; //对象
        for (int i : array) {
            if (count==0) res = i;
            count  += i==res?1:-1;
        }
        return res;
    }
}